﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SpiderContract;
using System.ServiceModel;

namespace TKWeb.Tool
{
	/// <summary>
	/// PushUrl 的摘要说明
	/// </summary>
	public class PushUrl : IHttpHandler
	{

		public void ProcessRequest(HttpContext context)
		{
			context.Response.ContentType = "text/plain";

			int jobId = 0;
			string urls = context.Request["urls"];
			int.TryParse(context.Request["jobId"], out jobId);

			using (ChannelFactory<ISpiderService> channelFactory = new ChannelFactory<ISpiderService>("TK.SpiderService"))
			{
				ISpiderService spider = channelFactory.CreateChannel();
				spider.ReCrawl(jobId, urls.Split(','));
			}
		}

		public bool IsReusable
		{
			get
			{
				return false;
			}
		}
	}
}